package com.tinem.platform.web.file.controller;

import cn.hutool.core.io.FileUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@Controller
@RequestMapping("/excel")
public class ExcelController {

    @ResponseBody
    @GetMapping("toJson.api")
    @ApiOperation(value = "excelexcel解析成json解析成json", httpMethod = "POST", notes = "暂无")
    public Object toJson(@RequestParam(value = "filePath") String filePath){
        ExcelReader reader = ExcelUtil.getReader(FileUtil.file(filePath));
        return reader.readAll();
    }
}
